/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.portlet.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.portlet.model.nhanvien;
import com.portlet.model.nhanvienModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the nhanvien service. Represents a row in the &quot;dtbase_nhanvien&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.portlet.model.nhanvienModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link nhanvienImpl}.
 * </p>
 *
 * @author Thi
 * @see nhanvienImpl
 * @see com.portlet.model.nhanvien
 * @see com.portlet.model.nhanvienModel
 * @generated
 */
public class nhanvienModelImpl extends BaseModelImpl<nhanvien>
	implements nhanvienModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a nhanvien model instance should use the {@link com.portlet.model.nhanvien} interface instead.
	 */
	public static final String TABLE_NAME = "dtbase_nhanvien";
	public static final Object[][] TABLE_COLUMNS = {
			{ "maNhanVien", Types.VARCHAR },
			{ "tenNhanVien", Types.VARCHAR },
			{ "gioiTinh", Types.VARCHAR },
			{ "ngaySinh", Types.TIMESTAMP },
			{ "maBoPhan", Types.VARCHAR },
			{ "maRole", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table dtbase_nhanvien (maNhanVien VARCHAR(75) not null primary key,tenNhanVien VARCHAR(75) null,gioiTinh VARCHAR(75) null,ngaySinh DATE null,maBoPhan VARCHAR(75) null,maRole VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table dtbase_nhanvien";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.portlet.model.nhanvien"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.portlet.model.nhanvien"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.portlet.model.nhanvien"));

	public nhanvienModelImpl() {
	}

	public String getPrimaryKey() {
		return _maNhanVien;
	}

	public void setPrimaryKey(String primaryKey) {
		setMaNhanVien(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _maNhanVien;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return nhanvien.class;
	}

	public String getModelClassName() {
		return nhanvien.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("maNhanVien", getMaNhanVien());
		attributes.put("tenNhanVien", getTenNhanVien());
		attributes.put("gioiTinh", getGioiTinh());
		attributes.put("ngaySinh", getNgaySinh());
		attributes.put("maBoPhan", getMaBoPhan());
		attributes.put("maRole", getMaRole());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String maNhanVien = (String)attributes.get("maNhanVien");

		if (maNhanVien != null) {
			setMaNhanVien(maNhanVien);
		}

		String tenNhanVien = (String)attributes.get("tenNhanVien");

		if (tenNhanVien != null) {
			setTenNhanVien(tenNhanVien);
		}

		String gioiTinh = (String)attributes.get("gioiTinh");

		if (gioiTinh != null) {
			setGioiTinh(gioiTinh);
		}

		Date ngaySinh = (Date)attributes.get("ngaySinh");

		if (ngaySinh != null) {
			setNgaySinh(ngaySinh);
		}

		String maBoPhan = (String)attributes.get("maBoPhan");

		if (maBoPhan != null) {
			setMaBoPhan(maBoPhan);
		}

		String maRole = (String)attributes.get("maRole");

		if (maRole != null) {
			setMaRole(maRole);
		}
	}

	public String getMaNhanVien() {
		if (_maNhanVien == null) {
			return StringPool.BLANK;
		}
		else {
			return _maNhanVien;
		}
	}

	public void setMaNhanVien(String maNhanVien) {
		_maNhanVien = maNhanVien;
	}

	public String getTenNhanVien() {
		if (_tenNhanVien == null) {
			return StringPool.BLANK;
		}
		else {
			return _tenNhanVien;
		}
	}

	public void setTenNhanVien(String tenNhanVien) {
		_tenNhanVien = tenNhanVien;
	}

	public String getGioiTinh() {
		if (_gioiTinh == null) {
			return StringPool.BLANK;
		}
		else {
			return _gioiTinh;
		}
	}

	public void setGioiTinh(String gioiTinh) {
		_gioiTinh = gioiTinh;
	}

	public Date getNgaySinh() {
		return _ngaySinh;
	}

	public void setNgaySinh(Date ngaySinh) {
		_ngaySinh = ngaySinh;
	}

	public String getMaBoPhan() {
		if (_maBoPhan == null) {
			return StringPool.BLANK;
		}
		else {
			return _maBoPhan;
		}
	}

	public void setMaBoPhan(String maBoPhan) {
		_maBoPhan = maBoPhan;
	}

	public String getMaRole() {
		if (_maRole == null) {
			return StringPool.BLANK;
		}
		else {
			return _maRole;
		}
	}

	public void setMaRole(String maRole) {
		_maRole = maRole;
	}

	@Override
	public nhanvien toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (nhanvien)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	public nhanvien toUnescapedModel() {
		return (nhanvien)this;
	}

	@Override
	public Object clone() {
		nhanvienImpl nhanvienImpl = new nhanvienImpl();

		nhanvienImpl.setMaNhanVien(getMaNhanVien());
		nhanvienImpl.setTenNhanVien(getTenNhanVien());
		nhanvienImpl.setGioiTinh(getGioiTinh());
		nhanvienImpl.setNgaySinh(getNgaySinh());
		nhanvienImpl.setMaBoPhan(getMaBoPhan());
		nhanvienImpl.setMaRole(getMaRole());

		nhanvienImpl.resetOriginalValues();

		return nhanvienImpl;
	}

	public int compareTo(nhanvien nhanvien) {
		String primaryKey = nhanvien.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof nhanvien)) {
			return false;
		}

		nhanvien nhanvien = (nhanvien)obj;

		String primaryKey = nhanvien.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<nhanvien> toCacheModel() {
		nhanvienCacheModel nhanvienCacheModel = new nhanvienCacheModel();

		nhanvienCacheModel.maNhanVien = getMaNhanVien();

		String maNhanVien = nhanvienCacheModel.maNhanVien;

		if ((maNhanVien != null) && (maNhanVien.length() == 0)) {
			nhanvienCacheModel.maNhanVien = null;
		}

		nhanvienCacheModel.tenNhanVien = getTenNhanVien();

		String tenNhanVien = nhanvienCacheModel.tenNhanVien;

		if ((tenNhanVien != null) && (tenNhanVien.length() == 0)) {
			nhanvienCacheModel.tenNhanVien = null;
		}

		nhanvienCacheModel.gioiTinh = getGioiTinh();

		String gioiTinh = nhanvienCacheModel.gioiTinh;

		if ((gioiTinh != null) && (gioiTinh.length() == 0)) {
			nhanvienCacheModel.gioiTinh = null;
		}

		Date ngaySinh = getNgaySinh();

		if (ngaySinh != null) {
			nhanvienCacheModel.ngaySinh = ngaySinh.getTime();
		}
		else {
			nhanvienCacheModel.ngaySinh = Long.MIN_VALUE;
		}

		nhanvienCacheModel.maBoPhan = getMaBoPhan();

		String maBoPhan = nhanvienCacheModel.maBoPhan;

		if ((maBoPhan != null) && (maBoPhan.length() == 0)) {
			nhanvienCacheModel.maBoPhan = null;
		}

		nhanvienCacheModel.maRole = getMaRole();

		String maRole = nhanvienCacheModel.maRole;

		if ((maRole != null) && (maRole.length() == 0)) {
			nhanvienCacheModel.maRole = null;
		}

		return nhanvienCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{maNhanVien=");
		sb.append(getMaNhanVien());
		sb.append(", tenNhanVien=");
		sb.append(getTenNhanVien());
		sb.append(", gioiTinh=");
		sb.append(getGioiTinh());
		sb.append(", ngaySinh=");
		sb.append(getNgaySinh());
		sb.append(", maBoPhan=");
		sb.append(getMaBoPhan());
		sb.append(", maRole=");
		sb.append(getMaRole());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.portlet.model.nhanvien");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>maNhanVien</column-name><column-value><![CDATA[");
		sb.append(getMaNhanVien());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tenNhanVien</column-name><column-value><![CDATA[");
		sb.append(getTenNhanVien());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>gioiTinh</column-name><column-value><![CDATA[");
		sb.append(getGioiTinh());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ngaySinh</column-name><column-value><![CDATA[");
		sb.append(getNgaySinh());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>maBoPhan</column-name><column-value><![CDATA[");
		sb.append(getMaBoPhan());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>maRole</column-name><column-value><![CDATA[");
		sb.append(getMaRole());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = nhanvien.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			nhanvien.class
		};
	private String _maNhanVien;
	private String _tenNhanVien;
	private String _gioiTinh;
	private Date _ngaySinh;
	private String _maBoPhan;
	private String _maRole;
	private nhanvien _escapedModel;
}